import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:jinke/page/pro_list/model/pro_list_model.dart';

import 'package:jinke/utils/util.dart';

import '../index.dart';

/// hello
class ProListCell extends GetView<ProListController> {
  const ProListCell({
    Key? key,
    required this.mod,
    required this.index,
  }) : super(key: key);
  final ProListModel mod;
  final int index;
  @override
  Widget build(BuildContext context) {
    var state = controller.state;
    return InkWell(
      onTap: () => controller.actionCell(mod),
      child: Container(
        margin: EdgeInsets.fromLTRB(16.r, 16.r, 16.r, 0),
        decoration: BoxDecoration(
            color: Colors.white, borderRadius: BorderRadius.circular(5.r)),
        child: Column(
          children: [
            index == 0
                ? Container(
                    height: 36.r,
                    padding: EdgeInsets.symmetric(horizontal: 16.r),
                    alignment: Alignment.centerLeft,
                    decoration: const BoxDecoration(
                      color: Color(0xffE7F2F9),
                    ),
                    child: Row(
                      children: [
                        Icon(
                          Icons.stars,
                          size: 22.r,
                          color: ColorsUtil.blue,
                        ),
                        SizedBox(
                          width: 10.r,
                        ),
                        Text(
                          '重点关注',
                          style: TextStyle(
                              color: ColorsUtil.title, fontSize: 14.sp),
                        ),
                      ],
                    ),
                  )
                : const SizedBox(),
            Container(
              padding: EdgeInsets.symmetric(horizontal: 16.r, vertical: 20.r),
              decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(5.r)),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          mod.projectAlias ?? '',
                          style: TextStyle(
                            color: ColorsUtil.title,
                            fontSize: 15.sp,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                        SizedBox(
                          height: 14.r,
                        ),
                        Row(
                          children: [
                            Container(
                              decoration: BoxDecoration(
                                color: const Color(0xffF2F3F7),
                                borderRadius: BorderRadius.circular(2.r),
                              ),
                              padding: EdgeInsets.symmetric(
                                  horizontal: 5.r, vertical: 2.r),
                              child: Text(
                                mod.phaseName ?? '',
                                style: TextStyle(
                                    color: ColorsUtil.subTitle,
                                    fontSize: 10.sp),
                              ),
                            ),
                            SizedBox(
                              width: 4.r,
                            ),
                            Container(
                              decoration: BoxDecoration(
                                color: const Color(0xffF2F3F7),
                                borderRadius: BorderRadius.circular(2.r),
                              ),
                              padding: EdgeInsets.symmetric(
                                  horizontal: 5.r, vertical: 2.r),
                              child: Text(
                                '${mod.investmentQuota ?? ''}亿',
                                style: TextStyle(
                                    color: ColorsUtil.subTitle,
                                    fontSize: 10.sp),
                              ),
                            ),
                          ],
                        ),
                        Container(
                          padding: EdgeInsets.fromLTRB(0, 10.r, 10.r, 0),
                          child: Text(
                            mod.dynamicTypeContent ?? '',
                            style: TextStyle(
                                color: const Color(0xffF14839),
                                fontSize: 12.sp),
                          ),
                        ),
                      ],
                    ),
                  ),
                  InkWell(
                    onTap: () {
                      controller.focus(mod);
                    },
                    child: Container(
                      width: 64.r,
                      height: 26.r,
                      alignment: Alignment.center,
                      decoration: getDecoration(mod.isFocus == 1),
                      child: Text(
                        mod.isFocus == 1 ? '已关注' : '关注',
                        style: TextStyle(
                          color: mod.isFocus == 1
                              ? ColorsUtil.subTitle
                              : Colors.white,
                        ),
                      ),
                    ),
                  )
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

  Decoration getDecoration(bool isFocus) {
    if (isFocus) {
      return BoxDecoration(
        color: const Color(0xffF2F3F7),
        borderRadius: BorderRadius.circular(2.r),
      );
    }
    return BoxDecoration(
        borderRadius: BorderRadius.circular(2.r),
        gradient: const LinearGradient(
          colors: [
            Color(0xff00A9FE),
            Color(0xff0173FE),
          ],
          begin: Alignment.centerLeft,
          end: Alignment.centerRight,
        ));
  }
}
